package com.pig.common;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author by 李志伟
 * Create Date: 2019/1/7 11:44
 * Description:
 */
public class Main {
    private static final int MAX_QUERY_LENGTH = 30;

    public static void main(String[] args) {
        List<Long> customCoffeeIdList = new ArrayList<>();

        for (long i = 0; i < 30; i++) {
            customCoffeeIdList.add(i);
        }

        int size = customCoffeeIdList.size();
        List<String> temp = new ArrayList<>();
        int times = size / MAX_QUERY_LENGTH;
        int mod = size % MAX_QUERY_LENGTH;
        for (int i = 0; i < times; i++) {
            List<Long> subList = customCoffeeIdList.subList(i * MAX_QUERY_LENGTH, (i + 1) * MAX_QUERY_LENGTH);
            List<String> LongList = getCustomCoffeeInfoByIds(subList, 0);
            temp.addAll(LongList);
        }
        List<Long> subList = customCoffeeIdList.subList(times * MAX_QUERY_LENGTH, times * MAX_QUERY_LENGTH + mod);
        List<String> LongList = getCustomCoffeeInfoByIds(subList, 0);
        temp.addAll(LongList);
        System.out.println(temp);
    }

    private static List<String> getCustomCoffeeInfoByIds(List<Long> subList, int i) {
        return subList.stream().map(v -> String.valueOf(v)).collect(Collectors.toList());
    }
}
